﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MPage.aspx.cs" Inherits="Jy123.Web.Manage.MPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理员－左菜单页面</title>
    <link href="css/custom/jquery.ui.css" rel="stylesheet" type="text/css" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery.js" type="text/javascript"></script>

    <script src="js/jquery.ui.js" type="text/javascript"></script>

    <script src="js/main.js" type="text/javascript"></script>

    <script language="javascript" type="text/jscript"> 
        function VFGroup(source, arguments)
        { 
            var txtGroup = document.getElementById('<%=txtGroup.ClientID %>');
            var dropGroup = document.getElementById('<%=dropGroup.ClientID %>');
            if(txtGroup.value==''&& (dropGroup.options[dropGroup.selectedIndex].text=='请选择'|| dropGroup.options[dropGroup.selectedIndex].text=='请添加分类'))
                arguments.IsValid=false; 
            else
                arguments.IsValid=true; 
        }
        $(function() {
        	$('#msg').dialog({
				autoOpen: false,
				modal: true
				}),
			$('#txtGroupName').keyup(function(){
			    if(this.value=='')
			        $("#btnAddGrup").attr({ disabled: true });
			    else
			        $("#btnAddGrup").attr({ disabled: false });
			})
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <h4>
        <a href="#"><span>页面管理</span></a></h4>
    <div class="register">
        <h5>
            名称</h5>
        <ul>
            <li>
                <input id="txtPame" type="text" class="text" runat="server" /></li>
            <li>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请输入页面名称"
                    CssClass="warning" Display="Dynamic" ControlToValidate="txtPame" ForeColor=""></asp:RequiredFieldValidator></li>
        </ul>
        <h5>
            URL</h5>
        <ul>
            <li>
                <input id="txtUrl" type="text" class="text" runat="server" /></li>
            <li>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="请输入页面URL"
                    CssClass="warning" Display="Dynamic" ControlToValidate="txtUrl" ForeColor=""></asp:RequiredFieldValidator></li>
        </ul>
        <h5>
            选择或设定分组</h5>
        <ul>
            <li>
                <asp:DropDownList ID="dropGroup" runat="server">
                </asp:DropDownList>
            </li>
            <li>
                <input id="txtGroup" type="text" class="text" runat="server" /></li>
            <li>
                <asp:CustomValidator ID="CustomValidator1" runat="server" CustomValidator="validator"
                    CssClass="warning" ErrorMessage="请选择或设定分组名称" ForeColor="" Display="Dynamic" ClientValidationFunction="VFGroup"></asp:CustomValidator></li>
            <li><a href="MGroup.aspx" class="btnsty">分组管理</a> </li>
        </ul>
        <ul class="bb">
            <li>
                <asp:Button ID="btnSubmit" CssClass="button" runat="server" Text="添 加" OnClick="btnSubmit_Click" /></li>
        </ul>
    </div>
    <asp:HiddenField ID="hidGroupID" runat="server" />
    <asp:GridView ID="GridView2" runat="server" CssClass="tblist" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True" DataKeyNames="ID"
        OnRowDataBound="GridView2_RowDataBound">
        <Columns>
            <asp:TemplateField HeaderText="名称" SortExpression="PName">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("PName") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" CssClass="tdtext" runat="server" Text='<%# Bind("PName") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="页面" SortExpression="Url">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Url") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" CssClass="tdtext" runat="server" Text='<%# Bind("Url") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="所在分组" SortExpression="UpID">
                <EditItemTemplate>
                    <asp:HiddenField ID="hidGroup" runat="server" Value='<%# Eval("UpID") %>' Visible="false">
                    </asp:HiddenField>
                    <asp:DropDownList ID="dropGroupList" runat="server" onchange="document.all.hidGroupID.value=this.value;">
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="labGroup" runat="server" Text='<%# GetGroupName(Eval("UpID")) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="操作" ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="编辑" CssClass="btnsty"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="删除" CssClass="btnsty cred"></asp:LinkButton>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Update" Text="更新" CssClass="btnsty"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="取消" CssClass="btnsty cred"></asp:LinkButton>
                </EditItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <div id="msg" title="提示">
    </div>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        DeleteCommand="DELETE FROM [Manage_Page] WHERE [ID] = @ID" 
        SelectCommand="SELECT [ID], [PName], [Url], [UpID] FROM [Manage_Page] WHERE ([UpID] &lt;&gt; @UpID) ORDER BY [ID] DESC"
        UpdateCommand="UPDATE [Manage_Page] SET [PName] = @PName, [Url] = @Url, [UpID] = @UpID WHERE [ID] = @ID"
        InsertCommand="INSERT INTO [Manage_Page] ([PName], [Url], [UpID]) VALUES (@PName, @Url, @UpID)">
        <SelectParameters>
            <asp:ControlParameter ControlID="dropGroup" Name="UpID" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
        <DeleteParameters> 
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="PName" Type="String" />
            <asp:Parameter Name="Url" Type="String" />
            <asp:ControlParameter ControlID="hidGroupID" Name="UpID" PropertyName="Value" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="PName" Type="String" />
            <asp:Parameter Name="Url" Type="String" />
            <asp:Parameter Name="UpID" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <% =Message %>
    </form>
</body>
</html>
